package svc

import (
	"github.com/zeromicro/go-zero/zrpc"
	"go-zero-project-02/rpc_study/user_api_rpc/api/internal/config"
	"go-zero-project-02/rpc_study/user_api_rpc/rpc/userclient"
)

type ServiceContext struct {
	Config  config.Config
	UserRpc userclient.User //rpc的客户端，来源于rpc服务定义的客户端，此处是rpc_study/user_api_rpc/rpc/userclient/user.go中的User interface
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:  c,
		UserRpc: userclient.NewUser(zrpc.MustNewClient(c.UserRpc)), //初始化rpc客户端
	}
}
